package com.friends.library.servlet;

import java.io.IOException;
import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.hibernate.Session;
import org.hibernate.Transaction;

import com.friends.library.Dto.StudentDetail1;
import com.friends.library.persistence.HibernateUtil;

public class StudentDetail extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     * @author HAVE A NICE DAY
     */
    public StudentDetail() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String cardno=request.getParameter("cardno");
		String studentname=request.getParameter("studentname");
		String collegename=request.getParameter("collegename");
		String sex=request.getParameter("sex");
		String course=request.getParameter("course");
		String branch=request.getParameter("branch");
		String year=request.getParameter("year");
		String address=request.getParameter("address");
		String city=request.getParameter("city");
		String zip=request.getParameter("zip");
		String email=request.getParameter("email");
		String mobile=request.getParameter("mobile");
	
	Session session=HibernateUtil.getSessionFactory().openSession();
	Transaction transaction=session.beginTransaction();
	StudentDetail1 detail1=new StudentDetail1();
	detail1.setCardno(cardno);
	detail1.setStudentname(studentname);
	detail1.setCollegename(collegename);
	detail1.setSex(sex);
	detail1.setCourse(course);
	detail1.setBranch(branch);
	detail1.setYear(year);
	detail1.setAddress(address);
	detail1.setCity(city);
	detail1.setZip(zip);
	detail1.setEmail(email);
	detail1.setMobile(mobile);
	
	session.save(detail1);
	transaction.commit();
	session.close();
	response.sendRedirect("studentdetails.jsp");
	}

}
